package com.qf.courtesycard.grabtickets.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @author 刘欣
 * @createTime 2023/3/10 16:46
 * @description
 */
@Configuration
public class SwaggerConfig {

    @Autowired
    private SwaggerProperties swaggerProperties;

    @Bean
    public Docket buildDocket() {
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(buildApiInfo()).select().apis(RequestHandlerSelectors.basePackage(swaggerProperties.packagePath)).build();
    }

    private ApiInfo buildApiInfo() {
        Contact qfeducation = new Contact(swaggerProperties.name, swaggerProperties.url, swaggerProperties.email);
        return new ApiInfoBuilder().contact(qfeducation).title(swaggerProperties.title).version(swaggerProperties.version).description(swaggerProperties.desc).build();
    }

}
